package app.kotlin_1.adapter

import android.content.Context
import android.widget.TextView
import app.kotlin_1.R
import app.kotlin_1.base.BaseRecyclerViewAdapter
import app.kotlin_1.base.BaseViewHolder
import app.kotlin_1.bean.NSearchBean
import app.kotlin_1.utils.toast

/**
 * Created by 刘智强 on 2017/9/27.
 */
class SearchContentAdapter : BaseRecyclerViewAdapter<NSearchBean> {
    private var context: Context? = null
    private var datas = mutableListOf<NSearchBean>()

    constructor(context: Context?, datas: MutableList<NSearchBean>, layoutId: Int?) : super(context, datas, layoutId) {
        this.context = context
        this.datas = datas
    }


    override fun bindData(viewHolder: BaseViewHolder, data: NSearchBean, position: Int) {
        var tvContent = viewHolder.getView<TextView>(R.id.tvContent)
        tvContent?.text = data?.name
        tvContent?.setOnClickListener { context?.toast(data.name) }
    }

    fun setData(searcList: MutableList<NSearchBean>?) {
        datas.clear()
        this.datas.addAll(searcList!!)
        notifyDataSetChanged()
    }

}

